package edu.hunau.cxb19.basic.class03;

/**
 *
 * @author hb
 *
 *         2020-02-11 15:16:22
 */
public class MoveBitDemo {

	public static void main(String[] args) {
		System.out.println(1 << 2);
		System.out.println(8 >> 2);
		System.out.println(-1 >>> 1);// 2147483647
		System.out.println(2147483647 << 1);// -2
		System.out.println(1 << 33);// 2

		System.out.println(3 & 7);// 3
		System.out.println(3 | 7);// 7
		System.out.println(3 ^ 7);// 4
		System.out.println(~3);

		byte b1 = 1;
		// 获得byte的低4位
		System.out.println(b1 & 0x0f);
		// 获得byte的高4位
		System.out.println(b1 >> 4 & 0x0f);

		// 获得两个数据的最大值
		int a1 = 100;
		int a2 = 200;
		int a3=1000;
		//实现三目运算符的嵌套
		int max = a1>a2?(a1>a3?a1:a3):(a2>a3?a2:a3);
		System.out.println(max);
		
		int a=5;
		System.out.println(a>4?9:9.0);


	}
}
